//封装数据库通用api

//加载数据库驱动
var mysql = require('mysql');

exports.base = (sql,data,callback) =>{
	//创建数据库连接
	var connection = mysql.createConnection({
	  host     : 'localhost',
	  user     : 'root',
	  password : '123456',
	  database : 'mycar'
	});
	//执行连接操作
	connection.connect();
	
	connection.query(sql,data, function (error, results, fields) {
	  if (error) throw error;
	  
	 callback(results);
	});
	
	connection.end();
	
	
}